﻿using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.AspNetCore.Mvc;
using YaAppoint.Appointments.Pools;

namespace YaAppoint.Web.Controllers
{
    public class PoolsController(IPoolAppService poolAppService) : AbpController
    {
        private readonly IPoolAppService _poolAppService = poolAppService;

        /// <summary>
        /// 提交新建
        /// </summary>
        [HttpPost("/api/pool/submit-create")]
        public async Task<IActionResult> SubmitCreate([FromBody]CreatePoolDto dto)
        {
            return new  JsonResult(await _poolAppService.SubmitCreate(dto));
        }

        /// <summary>
        /// 获取列表（分页）
        /// </summary>
        [HttpGet("/api/pool/load-pool-list")]
        public async Task<IActionResult> GetPoolList(Guid sid, int page, int pageSize)
        {
            return new JsonResult(await _poolAppService.GetPoolList(sid,page,pageSize));
        }


        /// <summary>
        /// 提交编辑
        /// </summary>
        [HttpPost("/api/pool/submit-edit")]
        public async Task<IActionResult> SubmitEdit([FromBody]PoolDto dto)
        {
            return new JsonResult(await _poolAppService.SubmitEdit(dto));
        }


        /// <summary>
        /// 获取详情
        /// </summary>
        [HttpGet("/api/pool/get")] 
        public async Task<IActionResult> GetAsync(Guid id)
        {
            return new JsonResult(await _poolAppService.GetAsync(id));
        }


        /// <summary>
        /// 单个删除
        /// </summary>
        [HttpDelete("/api/pool/delete")]
        public async Task<IActionResult> DeletePool(Guid id)
        {
            return new JsonResult(await _poolAppService.DeletePool(id));
        }

        /// <summary>
        /// 批量删除
        /// </summary>
        [HttpPost("/api/pool/delete-pool-many")]
        public async Task<IActionResult> DeletePoolMany([FromBody] List<Guid> idList)
        {
            return new JsonResult(await _poolAppService.DeletePoolMany(idList));
        }

        /// <summary>
        /// 批量创建特殊排班计划号池
        /// </summary>
        [HttpPost("/api/pool/batch-create")]
        public async Task<IActionResult> BatchCreate([FromBody] BatchCreatePoolModel batchModel, [FromQuery] Guid sid)
        {
            return new JsonResult(await _poolAppService.BatchCreate(batchModel,sid));
        }


        /// <summary>
        /// 启用禁用
        /// </summary>
        [HttpGet("/api/pool/enable-toggle")]
        public async Task<IActionResult> EnableToggle(Guid id)
        {
            return new JsonResult(await _poolAppService.EnableToggle(id));          
        }
    }
}
